package org.ooda.distributedsys.functionmodule.common;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: distributedSys
 * @description: RESTful implement class
 * @author: Aprilies
 * @create: 2023-03-18 00:22
 **/

public class ResponseHandler {
    public static ResponseEntity<Object> generateResponse(String message, HttpStatus status, Object responseObj) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("message", message);
        map.put("status", status.value());
        map.put("data", responseObj);

        return new ResponseEntity<Object>(map,HttpStatus.OK);
    }

    public static ResponseEntity<Object> generateResponse(String message, HttpStatus status, Object responseObj, HttpHeaders headers) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("message", message);
        map.put("status", status.value());
        map.put("data", responseObj);

        return new ResponseEntity<Object>(map, headers,HttpStatus.OK);
    }
}
